<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
    />
    <meta name="author" content="林镭特" />
    <title></title>
    
    <style></style>
  </head>
  <body>
    <!-- 计算距离某一天的时间 -->
    <p id="lastday"></p>
    <script>
      var p = document.querySelector("p");
      setInterval(fn, 1000);
        fn();
      function fn() {
        var now = new Date();
        var newyear = new Date("2020 1 25 00:00:00");
        var shicha = parseInt((newyear.getTime() - now.getTime()) / 1000);
        // console.log(shicha);
        var day = parseInt(shicha / (60 * 60 * 24));
        console.log(day);
        var hours = parseInt((shicha / (60 * 60)) % 24);
        var min = parseInt((shicha / 60) % 60);
        var sec = parseInt(shicha % 60);
        document.getElementById("lastday").innerHTML =
          '距离春节'+day + "天" + hours + "小时" + min + "分" + sec + "秒";
      }
    </script>
  </body>
</html>
